package com.blacktea.behavioralpatterns.interpreterpattern;

/**
 * @description: 等于
 *  具体的表达式类
 * @author: black tea
 * @date: 2023/3/25 15:22
 */
public class EqualsExpression implements Expression {
    private String variableName;
    private String value;

    public EqualsExpression(String variableName, String value) {
        this.variableName = variableName;
        this.value = value;
    }

    @Override
    public boolean interpret(Context context) {
        String variableValue = (String) context.getVariableValue(variableName);
        return variableValue != null && variableValue.equals(value);
    }
}
